/*******************************************************************************
* Copyright (c) 2010, 2018 西安秦晔信息科技有限公司
* Licensed under the Apache License, Version 2.0 (the "License");
*    you may not use this file except in compliance with the License.
*    You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*    Unless required by applicable law or agreed to in writing, software
*    distributed under the License is distributed on an "AS IS" BASIS,
*    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*    See the License for the specific language governing permissions and
*    limitations under the License.
*******************************************************************************/
package com.qinyeit.serviceapp.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.qinyeit.serviceapp.entity.enums.State;
import lombok.Builder;
import lombok.experimental.Tolerate;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.util.Date;

/**
 * ClassName: IntegralRule <br/>
 * Function: 积分规则 <br/>
 * date: 2018-12-04 10:49:12 <br/>
 *
 * @author liuwenjin
 * @version  1.0
 * @since JDK 1.8
 */
@Builder
@Entity
@Table(name="integral_rules")
public class IntegralRule extends MerchantGroupBaseEntity<Long> {

	private static final long serialVersionUID = 1L;

	// 名称 
    @Column(name="name", length = 300)
	private String name = null;

	// 消耗积分 
    @Column(name="integral",scale=2)
	private Double integral = null;

	// 兑换金额 
    @Column(name="amount",scale=2)
	private Double amount = null;

	// 有效期开始 
	@JSONField(format="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @Column(name="start_time")
	private Date startTime = null;

	// 有效期结束 
	@JSONField(format="yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
    @Column(name="end_time")
	private Date endTime = null;

	// 状态 
    @Column(name="state", length = 300)
	@Enumerated(EnumType.STRING)
	private State state = State.NORMAL;

	//创建的时候生成 编辑的时候不变
	@Column(name="uuid", length = 300)
	private String uuid = "";

	//更新的时间戳 long
	@Column(name="update_timestamp")
	private Long updateTimestamp = null;

    @Transient
	private String branchs = "";


	// 是否立即兑换
	@Column(name="immediately_exchange")
	private Boolean immediatelyExchange = false;




    @Tolerate
	public IntegralRule() {
		
	}
    @Tolerate
	public IntegralRule(Long id){
    	super.setId(id);
    }
	
	/**
	 * 获取名称
	 */
	public String getName() {
		return this.name;
	}

    /**
     * 设置名称
     */
	public IntegralRule setName(String name) {
		this.name = name;
		return this;
	}

	/**
	 * 获取消耗积分
	 */
	public Double getIntegral() {
		return this.integral;
	}

    /**
     * 设置消耗积分
     */
	public IntegralRule setIntegral(Double integral) {
		this.integral = integral;
		return this;
	}

	/**
	 * 获取兑换金额
	 */
	public Double getAmount() {
		return this.amount;
	}

    /**
     * 设置兑换金额
     */
	public IntegralRule setAmount(Double amount) {
		this.amount = amount;
		return this;
	}

	/**
	 * 获取有效期开始
	 */
	public Date getStartTime() {
		return this.startTime;
	}

    /**
     * 设置有效期开始
     */
	public IntegralRule setStartTime(Date startTime) {
		this.startTime = startTime;
		return this;
	}

	/**
	 * 获取有效期结束
	 */
	public Date getEndTime() {
		return this.endTime;
	}

    /**
     * 设置有效期结束
     */
	public IntegralRule setEndTime(Date endTime) {
		this.endTime = endTime;
		return this;
	}

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

	public String getBranchs() {
		return branchs;
	}

	public void setBranchs(String branchs) {
		this.branchs = branchs;
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}

	public Long getUpdateTimestamp() {
		return updateTimestamp;
	}

	public void setUpdateTimestamp(Long updateTimestamp) {
		this.updateTimestamp = updateTimestamp;
	}

	public Boolean getImmediatelyExchange() {
		return immediatelyExchange;
	}

	public void setImmediatelyExchange(Boolean immediatelyExchange) {
		this.immediatelyExchange = immediatelyExchange;
	}
}
